package com.jacky.javafx;

import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.image.Image;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.Border;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;

import javax.swing.*;


public class CoAPClient extends Application {

    @Override
    public void start(Stage rootStage) throws Exception {
        BorderPane bp = new BorderPane();
        bp.setPrefWidth(900);
        bp.setPrefHeight(715);

        // top
        MenuBar menuBar = new MenuBar();
        menuBar.prefWidth(585);
        menuBar.prefHeight(31);


        Menu menuFile = new Menu();
        menuFile.setText("File");
        Menu menuConn = new Menu();
        menuConn.setText("Connection");
        Menu menuDetail = new Menu();
        menuDetail.setText("CoAP Details");
        Menu menuLog = new Menu();
        menuLog.setText("Log");
        menuBar.getMenus().addAll(menuFile,menuConn,menuDetail,menuLog);
//        BorderPane.setAlignment(menuBar,Pos.CENTER);


        //left
        AnchorPane ap = new AnchorPane();
        TreeView<Object> treeView = new TreeView<>();
        TitledPane tp = new TitledPane("Resources",treeView);
        ap.getChildren().add(tp);
        BorderPane.setAlignment(ap,Pos.TOP_CENTER);




        // bottom
        AnchorPane logAP = new AnchorPane(new TextArea());
        TitledPane tpLog = new TitledPane("Log",logAP );
        Tab tabLog = new Tab("Log",tpLog);

        AnchorPane connAP = new AnchorPane(new TextArea());
        TitledPane tpConn = new TitledPane("Connection",connAP );
        Tab tabConn = new Tab("Connection",tpConn);

        TabPane tabPane = new TabPane(tabLog,tabConn);
        tabPane.maxWidth(Double.POSITIVE_INFINITY);


        bp.setBottom(tabPane);
        bp.setLeft(ap);
        Scene scene = new Scene(bp);

        rootStage.setScene(scene);
        rootStage.setTitle("FX CoAP Client");
        rootStage.getIcons().add(new Image("/icons/java.png"));
        rootStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}
